package com.lehecai.core.api.event;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangzq on 14-11-14.
 */
public class UserType extends IntegerBeanLabelItem {

    private static final Logger logger = LoggerFactory.getLogger(PropType.class.getName());

    private static List<UserType> items = new ArrayList<UserType>();
    private static List<UserType> queryItems = new ArrayList<UserType>();

    protected UserType(String name, int value, boolean queryOnly) {
        super(UserType.class.getName(), name, value);
        queryItems.add(this);
        if (!queryOnly) {
            items.add(this);
        }
    }

    protected UserType(String name, int value) {
        this(name, value, false);
    }

    public static UserType getItem(int value){
        try {
            return (UserType) UserType.getResult(UserType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    public static List<UserType> getItems() {
        return items;
    }

    public static List<UserType> getQueryItems() {
        return queryItems;
    }

    public static final UserType ALL = new UserType("全部", -1, true);
    public static final UserType ALLCONSUMER = new UserType("全部用户", 0);
    public static final UserType NEWCONSUMER = new UserType("新用户", 1);
}
